package ru.marketsoft.reminder.frames;

import ru.marketsoft.reminder.tools.Utils;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * User: dimka3210
 * Date: 02.03.13
 * Time: 1:35
 */
public class ErrorDialog extends JDialog {

    private JPanel context;
    private JLabel textLabel;

    public ErrorDialog(String text) {
        super();
        setContentPane(context);
        textLabel.setText(text);
        setModal(true);
        setIconImage(Utils.getIcon());
        pack();
        Dimension size = getSize();
        Dimension useScreen = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((int)(useScreen.getWidth()/2-size.getWidth()/2), (int)(useScreen.getHeight()/2-size.getHeight()/2));
        setVisible(true);

        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.out.println("windowClosing");
                System.exit(0);
            }

            @Override
            public void windowClosed(WindowEvent e) {
                System.out.println("windowClosed");
                System.exit(0);
            }
        });
    }
}
